var btnEvent = {
		fillCard:function(){
			var checked = recordTable.getSelectedRecords();
			if(checked == null || checked.length != 1){
				MsgBox.info("请选择一条记录");
			}else{
				//打开补卡页面
				var record = recordTable.getSelectedRecords();
				var loanNo = record[0].data.loanNo;
				var loanType = record[0].data.channelType;
				
				var dataObj = record[0].data;
				$.zui.store.set("dataObj",dataObj);
				MsgBox.open("altermateBankCard", "修改银行卡 ", "sms/custInfoEdit/altermateBankCard/"+loanNo+"/"+loanType,"1000px");
			}
		},
		editName:function(){
			var checked = recordTable.getSelectedRecords();
			if(checked == null || checked.length != 1){
				MsgBox.info("请选择一条记录");
			}else{
				//打开修改姓名页面
				var record = recordTable.getSelectedRecords();
				var loanNo = record[0].data.loanNo;
				var custName = record[0].data.custName;
				MsgBox.open("updateNameNoHis", "更改姓名 ", "sms/custInfoEdit/changeName/"+loanNo+"/"+custName,"500px");
			}
		}
};

//数据表格事件
var tableEvent = {
		onRender:function(colName,text,indexStr,mItem){
			switch(colName){
			case 'aprovResult'://审批结果
				text = multiCodes['aprovResult'][text];
				return text;
			case 'custOpenOrg'://开户行
				text = multiCodes['custOpenOrg'][text];
				return text;
			case 'bankInfo'://账户信息
				text = '<a href="javascript:void(0)" class="bankInfo">详细</a>';
				return text;
			case 'idCardInfo'://身份证信息
				text = '<a href="javascript:void(0)" class="idCardInfo">查看</a>';
				return text;
			case 'attachment'://附件
				text = '<a href="javascript:void(0)" class="attachmentInfo">预览</a>';
				return text;
			}
		},
		onReady:function(){
			$('.bankInfo').click(function(e){ //账户信息
				e.stopPropagation();
				e.preventDefault();
				var num = $(this).parents('tr').index();
				var record = recordTable.records[num].data;
				var topBody = MsgBox.getBody();
				topBody.find('.dataSpan').html('');
				topBody.find('#custAccount.dataSpan').html(record.custAccount);
				topBody.find('#custAccountName.dataSpan').html(record.custAccountName);
				topBody.find('#custOpenOrg.dataSpan').html(multiCodes['custOpenOrg'][record.custOpenOrg]);
				topBody.find('#custBranchProv.dataSpan').html(record.custBranchProv);
				topBody.find('#custBranchCity.dataSpan').html(record.custBranchCity);
				topBody.find('#custBranch.dataSpan').html(record.custBranch);
				MsgBox.trigger("bank", "客户账户信息", "#bankInfoDia");
			});
			
			$('.idCardInfo').click(function(e){//身份证信息
				e.stopPropagation();
				e.preventDefault();
				var num = $(this).parents('tr').index();
				var record = recordTable.records[num].data;
				var topBody = MsgBox.getBody();
				topBody.find('.cardSpan').html('');
				topBody.find('#certNo.cardSpan').html(record.certNo);
				topBody.find('#certIssuOrg.cardSpan').html(record.certIssuOrg);
				MsgBox.trigger("idCard", "身份证信息", "#idCardInfoDia");
			});
			
			$('.attachmentInfo').click(function(e){//附件信息
				e.stopPropagation();
				e.preventDefault();
				var num = $(this).parents('tr').index();
				var record = recordTable.records[num].data;
				window.open(ctx+'/sms/staffPcl/attachInfo/'+record.loanNo+"/"+record.custName);  
			});
		}
};

function searchByKey(){
	recordASPagination.resetPagination();
	queryRecords.send();
}
function getRec(){
	var record = recordTable.getSelectedRecords();
	return record;
}
function refreshTable(){
	queryRecords.send();
	recordTable.refresh();
}
function initSelect(){
	$('select[name="aprovResult"]').find('option').each(function(){
		var value = $(this).attr('value') || '';
		if(value != '' && value != '013001' && value != '013005'){
			$(this).remove();
		}
	});
}